package com.cea.papyrustest.uml.deletecommand;

import junit.framework.TestCase;

import org.eclipse.gef.commands.CommandStack;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.uml2.uml.Package;

import com.cea.papyrus.core.commands.PapyrusCommand;
import com.cea.papyrus.core.editor.MultiDiagramEditor;

/**
 * Generic test class for papyrus commands
 * @author Remi Schnekenburger
 */
public abstract class PapyrusCommandTest extends TestCase {
	protected PapyrusCommand papyrusCommand;
	protected Package model;
	protected CommandStack stack;
	
	/**
	 * Defautl constructor
	 * @param name the name of the test case
	 */
	public PapyrusCommandTest(String name) {
		super(name);
	}

	/* (non-Javadoc)
	 * @see junit.framework.TestCase#setUp()
	 */
	@Override
	protected void setUp() throws Exception {
		super.setUp();
		while( !(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()instanceof MultiDiagramEditor)){}
		IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
		model=((MultiDiagramEditor)editorPart).getModelManager().getTopPackageFromUMLResource();
		stack =(CommandStack)editorPart.getAdapter(CommandStack.class);
		
	}

	/* (non-Javadoc)
	 * @see junit.framework.TestCase#tearDown()
	 */
	@Override
	protected void tearDown() throws Exception {
		super.tearDown();
	}

	/**
	 * Tests execution of the command (execute, undo, redo)
	 */
	protected abstract void testExecute();
	

}
